package com.yanqu.road.entity.interactive;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.utils.string.StringUtils;

import java.util.ArrayList;
import java.util.List;

public class UserInteractive extends DataObject {

    private long userId;

    private long modifyTime;

    private List<Long> likeUserIdList = new ArrayList<>();

    private List<Long> hateUserIdList = new ArrayList<>();

    private long totalGiveLikeTimes;

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if(this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public long getModifyTime() {
        return modifyTime;
    }

    public void setModifyTime(long modifyTime) {
        if(this.modifyTime != modifyTime) {
            this.modifyTime = modifyTime;
            setUpdateOption();
        }
    }

    public void setLikeUserIdList(List<Long> likeUserIdList) {
        this.likeUserIdList = likeUserIdList;
        setUpdateOption();
    }

    public boolean hasLikeUserId(long userId){
        return likeUserIdList.contains(Long.valueOf(userId));
    }

    public int getLikeCount(){
        return likeUserIdList.size();
    }

    public void addLikeUserId(long userId){
        if(!hasLikeUserId(userId)){
            likeUserIdList.add(userId);
            setUpdateOption();
        }
    }

    public String getLikeUserIdListString(){
        return StringUtils.listToString(likeUserIdList, ',');
    }

    public void setHateUserIdList(List<Long> hateUserIdList) {
        this.hateUserIdList = hateUserIdList;
        setUpdateOption();
    }

    public boolean hasHateUserId(long userId){
        return hateUserIdList.contains(Long.valueOf(userId));
    }

    public void addHateUserId(long userId){
        if(!hasHateUserId(userId)){
            hateUserIdList.add(userId);
            setUpdateOption();
        }
    }

    public String getHateUserIdListString(){
        return StringUtils.listToString(hateUserIdList, ',');
    }

    public long getTotalGiveLikeTimes() {
        return totalGiveLikeTimes;
    }

    public void setTotalGiveLikeTimes(long totalGiveLikeTimes) {
        if(this.totalGiveLikeTimes != totalGiveLikeTimes) {
            this.totalGiveLikeTimes = totalGiveLikeTimes;
            setUpdateOption();
        }
    }
}
